<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>智慧社区管理系统 - AI功能原型</title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'Noto Sans SC', sans-serif;
        }
        
        :root {
            --primary: #3498db;
            --secondary: #2ecc71;
            --dark: #2c3e50;
            --light: #ecf0f1;
            --danger: #e74c3c;
            --warning: #f39c12;
            --success: #27ae60;
            --gray: #95a5a6;
        }
        
        body {
            background: linear-gradient(135deg, #1a2a6c, #b21f1f, #1a2a6c);
            color: #333;
            min-height: 100vh;
            padding: 20px;
        }
        
        .container {
            max-width: 1400px;
            margin: 0 auto;
        }
        
        header {
            background: rgba(255, 255, 255, 0.95);
            border-radius: 15px;
            padding: 20px 30px;
            margin-bottom: 25px;
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
            display: flex;
            align-items: center;
            justify-content: space-between;
        }
        
        .logo {
            display: flex;
            align-items: center;
            gap: 15px;
        }
        
        .logo-icon {
            background: var(--primary);
            color: white;
            width: 50px;
            height: 50px;
            border-radius: 12px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 24px;
        }
        
        .logo-text h1 {
            font-size: 1.8rem;
            font-weight: 700;
            color: var(--dark);
        }
        
        .logo-text p {
            font-size: 0.9rem;
            color: var(--gray);
            font-weight: 500;
        }
        
        .user-controls {
            display: flex;
            gap: 20px;
            align-items: center;
        }
        
        .notification {
            position: relative;
            font-size: 1.3rem;
            color: var(--dark);
            cursor: pointer;
        }
        
        .badge {
            position: absolute;
            top: -8px;
            right: -8px;
            background: var(--danger);
            color: white;
            width: 20px;
            height: 20px;
            border-radius: 50%;
            font-size: 0.7rem;
            display: flex;
            align-items: center;
            justify-content: center;
        }
        
        .user-profile {
            display: flex;
            align-items: center;
            gap: 10px;
            cursor: pointer;
        }
        
        .avatar {
            width: 45px;
            height: 45px;
            border-radius: 50%;
            background: linear-gradient(45deg, var(--primary), var(--secondary));
            display: flex;
            align-items: center;
            justify-content: center;
            color: white;
            font-weight: bold;
            font-size: 1.2rem;
        }
        
        .main-content {
            display: grid;
            grid-template-columns: 280px 1fr;
            gap: 25px;
        }
        
        .sidebar {
            background: rgba(255, 255, 255, 0.95);
            border-radius: 15px;
            padding: 25px 0;
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
        }
        
        .nav-item {
            padding: 15px 25px;
            display: flex;
            align-items: center;
            gap: 15px;
            cursor: pointer;
            transition: all 0.3s ease;
            border-left: 4px solid transparent;
        }
        
        .nav-item:hover, .nav-item.active {
            background: rgba(52, 152, 219, 0.1);
            border-left: 4px solid var(--primary);
            color: var(--primary);
        }
        
        .nav-item i {
            font-size: 1.2rem;
            width: 25px;
        }
        
        .content {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(500px, 1fr));
            gap: 25px;
        }
        
        .dashboard-card {
            background: rgba(255, 255, 255, 0.95);
            border-radius: 15px;
            padding: 25px;
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
        }
        
        .card-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            margin-bottom: 20px;
            padding-bottom: 15px;
            border-bottom: 1px solid #eee;
        }
        
        .card-title {
            display: flex;
            align-items: center;
            gap: 10px;
        }
        
        .card-title i {
            font-size: 1.4rem;
            color: var(--primary);
        }
        
        .card-title h2 {
            font-size: 1.4rem;
            color: var(--dark);
        }
        
        .card-actions {
            display: flex;
            gap: 15px;
        }

        .btn {
            padding: 8px 15px;
            border-radius: 8px;
            border: none;
            font-weight: 500;
            cursor: pointer;
            display: flex;
            align-items: center;
            gap: 8px;
            transition: all 0.3s ease;
        }

        /* 添加模态框样式 */
        .modal-overlay {
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: rgba(0, 0, 0, 0.5);
            display: flex;
            align-items: center;
            justify-content: center;
            z-index: 1000;
            visibility: hidden;
            opacity: 0;
            transition: all 0.3s ease;
        }

        .modal-overlay.active {
            visibility: visible;
            opacity: 1;
        }

        .modal {
            background: white;
            border-radius: 15px;
            width: 90%;
            max-width: 600px;
            max-height: 90vh;
            overflow-y: auto;
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
            transform: translateY(-20px);
            transition: transform 0.3s ease;
        }

        .modal-overlay.active .modal {
            transform: translateY(0);
        }

        .modal-header {
            padding: 20px 25px;
            border-bottom: 1px solid #eee;
            display: flex;
            align-items: center;
            justify-content: space-between;
        }

        .modal-title {
            font-size: 1.3rem;
            font-weight: 600;
            color: var(--dark);
        }

        .modal-close {
            background: none;
            border: none;
            font-size: 1.5rem;
            cursor: pointer;
            color: var(--gray);
            transition: color 0.3s ease;
        }

        .modal-close:hover {
            color: var(--danger);
        }

        .modal-body {
            padding: 25px;
        }

        .modal-footer {
            padding: 15px 25px;
            border-top: 1px solid #eee;
            display: flex;
            justify-content: flex-end;
            gap: 10px;
        }

        .form-group {
            margin-bottom: 20px;
        }

        .form-label {
            display: block;
            margin-bottom: 8px;
            font-weight: 500;
            color: var(--dark);
        }

        .form-control {
            width: 100%;
            padding: 12px 15px;
            border: 1px solid #ddd;
            border-radius: 8px;
            font-size: 1rem;
            transition: border-color 0.3s ease;
        }

        .form-control:focus {
            border-color: var(--primary);
            outline: none;
        }

        .form-select {
            width: 100%;
            padding: 12px 15px;
            border: 1px solid #ddd;
            border-radius: 8px;
            font-size: 1rem;
            background-color: white;
            transition: border-color 0.3s ease;
        }

        .form-select:focus {
            border-color: var(--primary);
            outline: none;
        }
        .btn-primary {
            background: var(--primary);
            color: white;
            padding: 10px 20px;
            font-size: 1rem;
            transition: all 0.3s ease;
        }
        
        .btn-outline {
            background: transparent;
            border: 1px solid var(--primary);
            color: var(--primary);
            padding: 10px 20px;
            font-size: 1rem;
            transition: all 0.3s ease;
        }
        
        .btn:hover {
            transform: translateY(-2px);
            box-shadow: 0 4px 8px rgba(0,0,0,0.1);
        }
        .btn-primary:hover {
            background: #2980b9;
        }
        .btn-outline:hover {
            background: rgba(52, 152, 219, 0.1);
        }
        
        .feature-list {
            display: flex;
            flex-direction: column;
            gap: 20px;
        }
        
        .feature-item {
            display: flex;
            gap: 15px;
            padding: 15px;
            border-radius: 10px;
            background: rgba(236, 240, 241, 0.5);
            transition: all 0.3s ease;
            cursor: pointer;
        }
        
        .feature-item:hover {
            background: rgba(52, 152, 219, 0.1);
            transform: translateX(5px);
        }
        
        .feature-icon {
            width: 50px;
            height: 50px;
            border-radius: 12px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 1.4rem;
            color: white;
        }
        
        .feature-icon.security {
            background: linear-gradient(45deg, #e74c3c, #f39c12);
        }
        
        .feature-icon.service {
            background: linear-gradient(45deg, #9b59b6, #3498db);
        }
        
        .feature-icon.parking {
            background: linear-gradient(45deg, #1abc9c, #2ecc71);
        }
        
        .feature-icon.energy {
            background: linear-gradient(45deg, #f1c40f, #e67e22);
        }
        
        .feature-content {
            flex: 1;
        }
        
        .feature-content h3 {
            font-size: 1.1rem;
            margin-bottom: 8px;
            color: var(--dark);
        }
        
        .feature-content p {
            font-size: 0.9rem;
            color: var(--gray);
            line-height: 1.5;
        }
        
        .status-indicator {
            display: flex;
            align-items: center;
            gap: 5px;
            font-size: 0.8rem;
            font-weight: 500;
        }
        
        .status-indicator.active {
            color: var(--success);
        }
        
        .status-dot {
            width: 10px;
            height: 10px;
            border-radius: 50%;
        }
        
        .status-dot.active {
            background: var(--success);
        }
        
        .camera-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
            gap: 20px;
            margin-top: 20px;
        }
        
        .camera-card {
            background: #f8f9fa;
            border-radius: 10px;
            overflow: hidden;
            box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
        }
        
        .camera-header {
            padding: 12px 15px;
            background: var(--dark);
            color: white;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }
        
        .camera-status {
            display: flex;
            align-items: center;
            gap: 5px;
            font-size: 0.8rem;
        }
        
        .camera-preview {
            height: 150px;
            background: linear-gradient(45deg, #7f7fd5, #86a8e7, #91eae4);
            position: relative;
            display: flex;
            align-items: center;
            justify-content: center;
            color: white;
            font-weight: bold;
        }
        
        .alert-badge {
            position: absolute;
            top: 10px;
            right: 10px;
            background: var(--danger);
            color: white;
            padding: 5px 10px;
            border-radius: 20px;
            font-size: 0.8rem;
            font-weight: 500;
        }
        
        .camera-footer {
            padding: 12px 15px;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }
        
        .stats-grid {
            display: grid;
            grid-template-columns: repeat(2, 1fr);
            gap: 15px;
            margin-top: 20px;
        }
        
        .stat-card {
            background: linear-gradient(135deg, var(--primary), #86a8e7);
            border-radius: 10px;
            padding: 20px;
            color: white;
            display: flex;
            flex-direction: column;
            gap: 10px;
        }
        
        .stat-card.warning {
            background: linear-gradient(135deg, var(--warning), #f6e58d);
        }
        
        .stat-card.danger {
            background: linear-gradient(135deg, var(--danger), #ff7979);
        }
        
        .stat-card.success {
            background: linear-gradient(135deg, var(--success), #6ab04c);
        }
        
        .stat-value {
            font-size: 2rem;
            font-weight: 700;
        }
        
        .stat-label {
            font-size: 0.9rem;
            opacity: 0.9;
        }
        
        .chat-container {
            display: flex;
            flex-direction: column;
            height: 400px;
            background: #f8f9fa;
            border-radius: 10px;
            overflow: hidden;
        }
        
        .chat-header {
            background: var(--dark);
            color: white;
            padding: 15px;
            display: flex;
            align-items: center;
            gap: 10px;
        }
        
        .chat-messages {
            flex: 1;
            padding: 20px;
            overflow-y: auto;
            display: flex;
            flex-direction: column;
            gap: 15px;
        }
        
        .message {
            max-width: 80%;
            padding: 12px 18px;
            border-radius: 18px;
            position: relative;
        }
        
        .message.bot {
            background: #e3f2fd;
            align-self: flex-start;
            border-bottom-left-radius: 5px;
        }
        
        .message.user {
            background: #dcf8c6;
            align-self: flex-end;
            border-bottom-right-radius: 5px;
        }
        
        .chat-input {
            display: flex;
            padding: 15px;
            background: white;
            border-top: 1px solid #eee;
        }
        
        .chat-input input {
            flex: 1;
            padding: 12px 15px;
            border: 1px solid #ddd;
            border-radius: 30px;
            outline: none;
        }
        
        .chat-input button {
            background: var(--primary);
            color: white;
            border: none;
            width: 45px;
            height: 45px;
            border-radius: 50%;
            margin-left: 10px;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
        }
        
        .parking-map {
            height: 400px;
            background: #e0f7fa;
            border-radius: 10px;
            margin-top: 20px;
            position: relative;
            overflow: hidden;
        }
        
        .parking-spot {
            position: absolute;
            width: 80px;
            height: 40px;
            background: var(--success);
            border-radius: 5px;
            display: flex;
            align-items: center;
            justify-content: center;
            color: white;
            font-weight: 500;
            cursor: pointer;
            transition: all 0.3s ease;
        }
        
        .parking-spot.occupied {
            background: var(--danger);
        }
        
        .parking-spot.reserved {
            background: var(--warning);
        }
        
        .parking-spot:hover {
            transform: scale(1.05);
        }
        
        .spot-1 { top: 30px; left: 30px; }
        .spot-2 { top: 30px; left: 140px; }
        .spot-3 { top: 30px; left: 250px; }
        .spot-4 { top: 100px; left: 30px; }
        .spot-5 { top: 100px; left: 140px; }
        .spot-6 { top: 100px; left: 250px; }
        .spot-7 { top: 170px; left: 30px; }
        .spot-8 { top: 170px; left: 140px; }
        .spot-9 { top: 170px; left: 250px; }
        .spot-10 { top: 240px; left: 30px; }
        .spot-11 { top: 240px; left: 140px; }
        .spot-12 { top: 240px; left: 250px; }
        .spot-13 { top: 310px; left: 30px; }
        .spot-14 { top: 310px; left: 140px; }
        .spot-15 { top: 310px; left: 250px; }
        
        .legend {
            display: flex;
            gap: 15px;
            margin-top: 15px;
            justify-content: center;
        }
        
        .legend-item {
            display: flex;
            align-items: center;
            gap: 5px;
            font-size: 0.9rem;
        }
        
        .legend-color {
            width: 20px;
            height: 20px;
            border-radius: 4px;
        }
        
        .legend-color.free {
            background: var(--success);
        }
        
        .legend-color.occupied {
            background: var(--danger);
        }
        
        .legend-color.reserved {
            background: var(--warning);
        }
        
        .energy-chart {
            display: flex;
            justify-content: space-between;
            align-items: flex-end;
            height: 200px;
            padding: 20px 0;
            margin-bottom: 30px;
            border-bottom: 1px solid var(--border-color);
        }

        .energy-chart .chart-bar {
            width: 15%;
            background: linear-gradient(to top, #e53e3e, #f56565);
            border-radius: 5px 5px 0 0;
            position: relative;
            transition: height 1s ease-in-out;
            border: 1px solid rgba(255,255,255,0.2);
            box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
        }

        .chart-value {
            position: absolute;
            top: -30px;
            left: 50%;
            transform: translateX(-50%);
            font-weight: bold;
            color: #dc2626;
            font-size: 1rem;
            text-shadow: 0 2px 4px rgba(0,0,0,0.15);
        }

        .chart-bar-label {
            position: absolute;
            bottom: -25px;
            left: 50%;
            transform: translateX(-50%);
            color: #475569;
            font-size: 0.8rem;
        }
        
        .chart-value {
            color: white;
            padding: 5px;
            font-size: 0.9rem;
            font-weight: 500;
        }
        
        .device-list {
            display: flex;
            flex-direction: column;
            gap: 15px;
            margin-top: 20px;
        }
        
        .device-item {
            display: flex;
            align-items: center;
            padding: 15px;
            background: #f8f9fa;
            border-radius: 10px;
            gap: 15px;
        }
        
        .device-icon {
            width: 50px;
            height: 50px;
            border-radius: 10px;
            background: linear-gradient(45deg, var(--primary), var(--secondary));
            display: flex;
            align-items: center;
            justify-content: center;
            color: white;
            font-size: 1.4rem;
        }
        
        .device-info {
            flex: 1;
        }
        
        .device-info h3 {
            font-size: 1rem;
            margin-bottom: 5px;
        }
        
        .device-status {
            font-size: 0.85rem;
            color: var(--success);
            font-weight: 500;
        }
        
        .device-status.warning {
            color: var(--warning);
        }
        
        .device-status.danger {
            color: var(--danger);
        }
        
        .progress-bar {
            height: 8px;
            width: 100%;
            background: #e0e0e0;
            border-radius: 4px;
            margin-top: 5px;
            overflow: hidden;
        }
        
        .progress {
            height: 100%;
            background: var(--success);
            border-radius: 4px;
        }
        
        .progress.warning {
            background: var(--warning);
        }
        
        .progress.danger {
            background: var(--danger);
        }
        
        footer {
            margin-top: 40px;
            text-align: center;
            color: rgba(255, 255, 255, 0.7);
            font-size: 0.9rem;
            padding: 20px;
        }
        
        @media (max-width: 1100px) {
            .main-content {
                grid-template-columns: 1fr;
            }
            
            .sidebar {
                display: none;
            }
            
            .content {
                grid-template-columns: 1fr;
            }
        }
    </style>
</head>
<body>
    <div class="container">
        <header>
            <div class="logo">
                <div class="logo-icon">
                    <i class="fas fa-brain"></i>
                </div>
                <div class="logo-text">
                    <h1>智慧社区管理系统</h1>
                    <p>AI赋能 · 智能管理 · 安全便捷</p>
                </div>
            </div>
            <div class="user-controls">
                    <button class="btn btn-primary" onclick="window.location.href='shoye.html'">
                        <i class="fas fa-home"></i> 返回首页
                    </button>
                    <div class="user-profile">
                    <div class="avatar">管</div>
                    <div>
                        <div>管理员</div>
                        <div style="font-size: 0.8rem; color: var(--gray);">物业中心</div>
                    </div>
                </div>
            </div>
        </header>
        
        <div class="main-content">
            <div class="sidebar">
                <div class="nav-item" data-target="security">
                    <i class="fas fa-shield-alt"></i>
                    <span>智能安防</span>
                </div>
                <div class="nav-item" data-target="ai-service">
                    <i class="fas fa-robot"></i>
                    <span>AI客服</span>
                </div>
                <div class="nav-item" data-target="parking">
                    <i class="fas fa-car"></i>
                    <span>停车管理</span>
                </div>
                <div class="nav-item" data-target="energy">
                    <i class="fas fa-bolt"></i>
                    <span>能源管理</span>
                </div>
            </div>
            
            <div class="content">
                <!-- AI智能安防监控 -->
                <div class="dashboard-card" id="security" style="display: none;">
                    <div class="card-header">
                        <div class="card-title">
                            <i class="fas fa-shield-alt"></i>
                            <h2>AI智能安防监控</h2>
                        </div>
                        <div class="card-actions">
                            <button class="btn btn-outline" id="openSettingsBtn">
                                <i class="fas fa-cog"></i> 设置
                            </button>
                            <button class="btn btn-primary" id="openAddDeviceBtn">
                                <i class="fas fa-plus"></i> 添加设备
                            </button>
                        </div>
                    </div>
                    
                    <div class="camera-grid">
                        <div class="camera-card">
                            <div class="camera-header">
                                <div>1号楼大厅</div>
                                <div class="camera-status">
                                    <div class="status-dot active"></div>
                                    <span>运行中</span>
                                </div>
                            </div>
                            <div class="camera-preview">
                                人脸识别门禁
                                <div class="alert-badge">识别中</div>
                            </div>
                            <div class="camera-footer">
                                <div>今日通行: 142人</div>
                                <div><i class="fas fa-history"></i> 实时</div>
                            </div>
                        </div>
                        
                        <div class="camera-card">
                            <div class="camera-header">
                                <div>儿童游乐区</div>
                                <div class="camera-status">
                                    <div class="status-dot active"></div>
                                    <span>运行中</span>
                                </div>
                            </div>
                            <div class="camera-preview">
                                行为分析监控
                                <div class="alert-badge">异常检测</div>
                            </div>
                            <div class="camera-footer">
                                <div>今日告警: 1次</div>
                                <div><i class="fas fa-history"></i> 实时</div>
                            </div>
                        </div>
                        
                        <div class="camera-card">
                            <div class="camera-header">
                                <div>3号楼电梯</div>
                                <div class="camera-status">
                                    <div class="status-dot active"></div>
                                    <span>运行中</span>
                                </div>
                            </div>
                            <div class="camera-preview">
                                电动车识别系统
                                <div class="alert-badge">已阻止</div>
                            </div>
                            <div class="camera-footer">
                                <div>今日阻止: 3次</div>
                                <div><i class="fas fa-history"></i> 实时</div>
                            </div>
                        </div>
                    </div>
                    
                    <div class="stats-grid">
                        <div class="stat-card">
                            <div class="stat-value">98.7%</div>
                            <div class="stat-label">人脸识别准确率</div>
                        </div>
                        <div class="stat-card warning">
                            <div class="stat-value">12</div>
                            <div class="stat-label">今日异常行为</div>
                        </div>
                        <div class="stat-card danger">
                            <div class="stat-value">3</div>
                            <div class="stat-label">黑名单预警</div>
                        </div>
                        <div class="stat-card success">
                            <div class="stat-value">100%</div>
                            <div class="stat-label">设备在线率</div>
                        </div>
                    </div>
                </div>
                
                <!-- AI物业客服机器人 -->
                <div class="dashboard-card" id="ai-service" style="display: none;">
                    <div class="card-header">
                        <div class="card-title">
                            <i class="fas fa-robot"></i>
                            <h2>AI物业客服机器人</h2>
                        </div>
                        <div class="card-actions">
                            <button class="btn btn-outline">
                                <i class="fas fa-history"></i> 历史记录
                            </button>
                        </div>
                    </div>
                    
                    <div class="chat-container">
                        <div class="chat-header">
                            <i class="fas fa-robot"></i>
                            <div>AI物业助手 - 24小时在线服务</div>
                        </div>
                        <div class="chat-messages">
                            <div class="message bot">
                                您好！我是智慧社区AI助手，请问有什么可以帮您？我可以处理报修、缴费查询等业务。
                            </div>
                            <div class="message user">
                                我家卫生间水管漏水了，需要报修。
                            </div>
                            <div class="message bot">
                                好的，正在为您创建报修工单...
                                <br><br>
                                ✅ 工单类型: 水管维修
                                <br>
                                📍 位置: 8号楼2单元1203室
                                <br>
                                👨‍🔧 分配维修人员: 张师傅
                                <br>
                                ⏱ 预计到达时间: 30分钟内
                            </div>
                            <div class="message bot">
                                需要我帮您联系张师傅说明具体情况吗？
                            </div>
                        </div>
                        <div class="chat-input">
                            <input type="text" placeholder="输入您的问题...">
                            <button><i class="fas fa-paper-plane"></i></button>
                        </div>
                    </div>
                    
                    <div class="stats-grid">
                        <div class="stat-card">
                            <div class="stat-value">97.3%</div>
                            <div class="stat-label">问题解决率</div>
                        </div>
                        <div class="stat-card success">
                            <div class="stat-value">24/7</div>
                            <div class="stat-label">全天候服务</div>
                        </div>
                        <div class="stat-card">
                            <div class="stat-value">8</div>
                            <div class="stat-label">支持语言</div>
                        </div>
                        <div class="stat-card warning">
                            <div class="stat-value">2.1s</div>
                            <div class="stat-label">平均响应时间</div>
                        </div>
                    </div>
                </div>
                
                <!-- 智能停车管理 -->
                <div class="dashboard-card" id="parking" style="display: none;">
                    <div class="card-header">
                        <div class="card-title">
                            <i class="fas fa-car"></i>
                            <h2>智能停车管理</h2>
                        </div>
                        <div class="card-actions">
                            <button class="btn btn-outline">
                                <i class="fas fa-sync"></i> 刷新
                            </button>
                        </div>
                    </div>
                    
                    <div class="feature-item">
                        <div class="feature-icon parking">
                            <i class="fas fa-car"></i>
                        </div>
                        <div class="feature-content">
                            <h3>车牌识别系统</h3>
                            <p>自动识别业主车辆，无感通行；访客车辆自动登记并分配临时车位</p>
                        </div>
                        <div class="status-indicator active">
                            <div class="status-dot active"></div>
                            <span>在线</span>
                        </div>
                    </div>
                    
                    <div class="parking-map">
                        <div class="parking-spot spot-1">A01</div>
                        <div class="parking-spot spot-2 occupied">A02</div>
                        <div class="parking-spot spot-3">A03</div>
                        <div class="parking-spot spot-4">A04</div>
                        <div class="parking-spot spot-5 occupied">A05</div>
                        <div class="parking-spot spot-6 reserved">A06</div>
                        <div class="parking-spot spot-7">A07</div>
                        <div class="parking-spot spot-8 occupied">A08</div>
                        <div class="parking-spot spot-9">A09</div>
                        <div class="parking-spot spot-10">A10</div>
                        <div class="parking-spot spot-11 occupied">A11</div>
                        <div class="parking-spot spot-12">A12</div>
                        <div class="parking-spot spot-13 reserved">A13</div>
                        <div class="parking-spot spot-14">A14</div>
                        <div class="parking-spot spot-15 occupied">A15</div>
                    </div>
                    
                    <div class="legend">
                        <div class="legend-item">
                            <div class="legend-color free"></div>
                            <span>空闲车位</span>
                        </div>
                        <div class="legend-item">
                            <div class="legend-color occupied"></div>
                            <span>已占用</span>
                        </div>
                        <div class="legend-item">
                            <div class="legend-color reserved"></div>
                            <span>已预约</span>
                        </div>
                    </div>
                    
                    <div class="stats-grid">
                        <div class="stat-card">
                            <div class="stat-value">700</div>
                            <div class="stat-label">总车位数量</div>
                        </div>
                        <div class="stat-card success">
                            <div class="stat-value">224</div>
                            <div class="stat-label">空闲车位</div>
                        </div>
                        <div class="stat-card warning">
                            <div class="stat-value">15</div>
                            <div class="stat-label">访客车位</div>
                        </div>
                        <div class="stat-card danger">
                            <div class="stat-value">3</div>
                            <div class="stat-label">违规停车</div>
                        </div>
                    </div>
                </div>
                
                <!-- AI能源与设备管理 -->
                <div class="dashboard-card" id="energy" style="display: none;">
                    <div class="card-header">
                        <div class="card-title">
                            <i class="fas fa-bolt"></i>
                            <h2>AI能源与设备管理</h2>
                        </div>
                        <div class="card-actions">
                            <button class="btn btn-outline">
                                <i class="fas fa-chart-bar"></i> 详细数据
                            </button>
                        </div>
                    </div>
                    
                    <div class="feature-item">
                        <div class="feature-icon energy">
                            <i class="fas fa-lightbulb"></i>
                        </div>
                        <div class="feature-content">
                            <h3>能耗优化系统</h3>
                            <p>实时分析社区能耗，自动调节公共照明和空调系统，节能高达30%</p>
                        </div>
                        <div class="status-indicator active">
                            <div class="status-dot active"></div>
                            <span>运行中</span>
                        </div>
                    </div>
                    
                    <div class="energy-chart">
                        <div class="chart-bar" style="height: 70%;">
                            <div class="chart-value">72.3kWh</div>
                            <div class="chart-bar-label">照明</div>
                        </div>
                        <div class="chart-bar" style="height: 85%;">
                            <div class="chart-value">88.1kWh</div>
                            <div class="chart-bar-label">电梯</div>
                        </div>
                        <div class="chart-bar" style="height: 45%;">
                            <div class="chart-value">46.7kWh</div>
                            <div class="chart-bar-label">水泵</div>
                        </div>
                        <div class="chart-bar" style="height: 60%;">
                            <div class="chart-value">62.4kWh</div>
                            <div class="chart-bar-label">门禁</div>
                        </div>
                        <div class="chart-bar" style="height: 30%;">
                            <div class="chart-value">32.9kWh</div>
                            <div class="chart-bar-label">监控</div>
                        </div>
                    </div>
                    
                    <div class="device-list">
                        <div class="device-item">
                            <div class="device-icon">
                                <i class="fas fa-tint"></i>
                            </div>
                            <div class="device-info">
                                <h3>二次供水系统</h3>
                                <div class="device-status">运行正常</div>
                                <div class="progress-bar">
                                    <div class="progress" style="width: 65%;"></div>
                                </div>
                            </div>
                            <div>65%</div>
                        </div>
                        
                        <div class="device-item">
                            <div class="device-icon">
                                <i class="fas fa-wind"></i>
                            </div>
                            <div class="device-info">
                                <h3>新风系统</h3>
                                <div class="device-status warning">滤网需更换</div>
                                <div class="progress-bar">
                                    <div class="progress warning" style="width: 85%;"></div>
                                </div>
                            </div>
                            <div>85%</div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        
        <footer>
            &copy; 2024 智慧社区管理系统. All rights reserved.
        </footer>

        <!-- 设置模态框 -->
        <div class="modal-overlay" id="settingsModal">
            <div class="modal">
                <div class="modal-header">
                    <h3 class="modal-title">智能安防设置</h3>
                    <button class="modal-close" id="closeSettingsModal">&times;</button>
                </div>
                <div class="modal-body">
                    <div class="form-group">
                        <label class="form-label">人脸识别灵敏度</label>
                        <select class="form-select" id="faceRecognitionSensitivity">
                            <option value="low">低 (低误识率)</option>
                            <option value="medium" selected>中 (平衡)</option>
                            <option value="high">高 (高识别率)</option>
                        </select>
                    </div>
                    <div class="form-group">
                        <label class="form-label">异常行为检测</label>
                        <select class="form-select" id="abnormalBehaviorDetection">
                            <option value="off">关闭</option>
                            <option value="low">低灵敏度</option>
                            <option value="medium" selected>中灵敏度</option>
                            <option value="high">高灵敏度</option>
                        </select>
                    </div>
                    <div class="form-group">
                        <label class="form-label">告警通知方式</label>
                        <div style="display: flex; gap: 15px; margin-top: 8px;">
                            <label style="display: flex; align-items: center; gap: 5px;">
                                <input type="checkbox" checked> 系统内通知
                            </label>
                            <label style="display: flex; align-items: center; gap: 5px;">
                                <input type="checkbox" checked> 短信通知
                            </label>
                            <label style="display: flex; align-items: center; gap: 5px;">
                                <input type="checkbox"> 邮件通知
                            </label>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="form-label">录像存储时长</label>
                        <select class="form-select" id="recordingStorageDuration">
                            <option value="7">7天</option>
                            <option value="15" selected>15天</option>
                            <option value="30">30天</option>
                            <option value="90">90天</option>
                        </select>
                    </div>
                </div>
                <div class="modal-footer">
                    <button class="btn btn-outline" id="cancelSettings">取消</button>
                    <button class="btn btn-primary" id="saveSettings">保存设置</button>
                </div>
            </div>
        </div>

        <!-- 添加设备模态框 -->
        <div class="modal-overlay" id="addDeviceModal">
            <div class="modal">
                <div class="modal-header">
                    <h3 class="modal-title">添加新设备</h3>
                    <button class="modal-close" id="closeAddDeviceModal">&times;</button>
                </div>
                <div class="modal-body">
                    <div class="form-group">
                        <label class="form-label">设备名称</label>
                        <input type="text" class="form-control" id="deviceName" placeholder="例如：1号楼大厅摄像头">
                    </div>
                    <div class="form-group">
                        <label class="form-label">设备类型</label>
                        <select class="form-select" id="deviceType">
                            <option value="camera">监控摄像头</option>
                            <option value="doorlock">智能门锁</option>
                            <option value="sensor">红外传感器</option>
                            <option value="alarm">报警器</option>
                        </select>
                    </div>
                    <div class="form-group">
                        <label class="form-label">安装位置</label>
                        <input type="text" class="form-control" id="installationLocation" placeholder="例如：1号楼大厅入口">
                    </div>
                    <div class="form-group">
                        <label class="form-label">设备IP地址</label>
                        <input type="text" class="form-control" id="deviceIp" placeholder="例如：192.168.1.100">
                    </div>
                    <div class="form-group">
                        <label class="form-label">设备序列号</label>
                        <input type="text" class="form-control" id="deviceSerialNumber" placeholder="设备背面的序列号">
                    </div>
                </div>
                <div class="modal-footer">
                    <button class="btn btn-outline" id="cancelAddDevice">取消</button>
                    <button class="btn btn-primary" id="confirmAddDevice">添加设备</button>
                </div>
            </div>
        </div>

    </div>
    <script>
        document.addEventListener('DOMContentLoaded', function() {
            // 默认显示第一个板块
            document.querySelector('.nav-item').classList.add('active');
            document.getElementById('security').style.display = 'block';

            // 能源图表动态更新
            function updateEnergyChart() {
                const bars = document.querySelectorAll('.energy-chart .chart-bar');
                bars.forEach(bar => {
                    // 生成50-90%之间的随机高度
                    const newHeight = Math.floor(Math.random() * 40) + 50 + '%';
                    const valueElement = bar.querySelector('.chart-value');
                    const currentValue = parseFloat(valueElement.textContent);
                    const newValue = (currentValue * (parseInt(newHeight) / 100)).toFixed(1) + 'kWh';

                    // 更新高度和数值
                    bar.style.height = newHeight;
                    valueElement.textContent = newValue;
                });
            }

            // 打开设置模态框
            document.getElementById('openSettingsBtn').addEventListener('click', function() {
                document.getElementById('settingsModal').classList.add('active');
            });

            // 打开添加设备模态框
            document.getElementById('openAddDeviceBtn').addEventListener('click', function() {
                document.getElementById('addDeviceModal').classList.add('active');
            });

            // 关闭模态框的通用函数
            function closeModal(modalId) {
                document.getElementById(modalId).classList.remove('active');
            }

            // 为所有关闭按钮添加事件
            document.getElementById('closeSettingsModal').addEventListener('click', function() {
                closeModal('settingsModal');
            });

            document.getElementById('cancelSettings').addEventListener('click', function() {
                closeModal('settingsModal');
            });

            document.getElementById('closeAddDeviceModal').addEventListener('click', function() {
                closeModal('addDeviceModal');
            });

            document.getElementById('cancelAddDevice').addEventListener('click', function() {
                closeModal('addDeviceModal');
            });

            // 点击模态框背景关闭
            document.querySelectorAll('.modal-overlay').forEach(overlay => {
                overlay.addEventListener('click', function(e) {
                    if (e.target === this) {
                        this.classList.remove('active');
                    }
                });
            });

            // 初始加载时更新一次
            updateEnergyChart();
            // 每5秒自动更新一次
            setInterval(updateEnergyChart, 5000);

            // 聊天功能实现
            const chatInput = document.querySelector('.chat-input input');
            const chatButton = document.querySelector('.chat-input button');
            const chatMessages = document.querySelector('.chat-messages');

            function sendMessage() {
                const messageText = chatInput.value.trim();
                if (messageText) {
                    // 添加用户消息
                    const userMessage = document.createElement('div');
                    userMessage.className = 'message user';
                    userMessage.textContent = messageText;
                    chatMessages.appendChild(userMessage);

                    // 清空输入框
                    chatInput.value = '';

                    // 集成DeepSeek API处理消息
            const deepSeekApiKey = 'YOUR_DEEPSEEK_API_KEY'; // 请替换为您的DeepSeek API密钥
            const apiUrl = 'https://api.deepseek.com/v1/chat/completions';

            // 构建API请求数据
            const requestData = {
                model: 'deepseek-chat',
                messages: [{
                    role: 'user',
                    content: `分析以下消息并判断意图:\n${messageText}\n\n意图只能是"报修"或"缴费查询"，如果无法判断则返回"未知"。\n如果是报修，请提取标题、类型(水电维修/电梯故障/公共设施/安防系统/其他)、位置、优先级(高/中/低)、描述。\n如果是缴费查询，请提取住户姓名。\n返回JSON格式，不要包含其他文本。`
                }]
            };

            // 发送请求到DeepSeek API
            fetch(apiUrl, {
                method: 'POST',
                headers: {
                    'Content-Type': 'application/json',
                    'Authorization': `Bearer ${deepSeekApiKey}`
                },
                body: JSON.stringify(requestData)
            })
            .then(response => response.json())
            .then(data => {
                try {
                    // 尝试解析API响应
let result;
const responseContent = data.choices[0].message.content;
// 清理可能的额外文本，只保留JSON部分
const jsonMatch = responseContent.match(/\{[\s\S]*\}/);
if (jsonMatch) {
  try {
    result = JSON.parse(jsonMatch[0]);
  } catch (parseError) {
    console.error('JSON解析错误:', parseError, '原始内容:', jsonMatch[0]);
    throw new Error('无法解析API响应内容');
  }
} else {
  console.error('未找到有效的JSON内容:', responseContent);
  throw new Error('API响应格式不正确');
}
                    const botMessage = document.createElement('div');
                    botMessage.className = 'message bot';

                    // 处理报修意图
                    if (result.intent === '报修') {
                        // 构造报修数据
                        const repairData = {
                            title: result.title || 'AI自动创建报修',
                            type: result.type || 'other',
                            location: result.location || 'public_area',
                            priority: result.priority === '高' ? 'critical' : result.priority === '中' ? 'urgent' : 'normal',
                            username: result.username || 'AI用户',
                            phone: '138****0000', // 默认电话，实际应用中可从用户信息获取
                            address: result.location || '未知位置',
                            description: result.description || 'AI自动创建的报修单'
                        };

                        // 调用repair.html中的全局函数创建报修单
                        if (window.createRepairTicket) {
                            const newTicket = window.createRepairTicket(repairData);
                            botMessage.innerHTML = `已为您创建报修单:<br>单号: ${newTicket.id}<br>标题: ${newTicket.title}<br>状态: 待处理`;
                        } else {
                            // 备份到localStorage，当repair.html打开时会自动加载
                            localStorage.setItem('newRepairFromAI', JSON.stringify(repairData));
                            botMessage.innerHTML = `已为您创建报修单:<br>系统将在您打开报修页面时自动同步数据`;
                        }

                    // 处理缴费查询意图
                    } else if (result.intent === '缴费查询') {
    // 修复字段名从username改为residentName
    const residentName = result.residentName || result.username;
                        if (!residentName) {
                            botMessage.textContent = '请提供要查询的住户姓名';
                            chatMessages.appendChild(botMessage);
                            return;
                        }

                        // 从localStorage获取费用数据
                        const feeData = JSON.parse(localStorage.getItem('feeData') || '{}');
                        const residentFees = [];

                        // 查找该住户的所有费用
                        for (const [id, fee] of Object.entries(feeData)) {
                            if (fee.resident.includes(residentName)) {
                                residentFees.push({id, ...fee});
                            }
                        }

                        if (residentFees.length > 0) {
                            let responseText = `${residentName}的费用信息如下:<br>`;
                            residentFees.forEach(fee => {
                                // 使用统一的货币格式化显示金额
                             responseText += `- ${fee.type}: ¥${parseFloat(fee.amount).toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,')} (${fee.status})<br>`;
                            });
                            botMessage.innerHTML = responseText;
                        } else {
                            botMessage.textContent = `未找到${residentName}的费用记录`;
                        }

                    // 未知意图
                    } else {
                        botMessage.textContent = '抱歉，我无法理解您的请求。请说明是报修还是缴费查询。';
                    }

                    chatMessages.appendChild(botMessage);
                    chatMessages.scrollTop = chatMessages.scrollHeight;
                } catch (error) {
                    const errorMessage = document.createElement('div');
                    errorMessage.className = 'message bot';
                    errorMessage.textContent = '处理请求时出错，请稍后重试。';
                    chatMessages.appendChild(errorMessage);
                    chatMessages.scrollTop = chatMessages.scrollHeight;
                }
            })
            .catch(error => {
                const errorMessage = document.createElement('div');
                errorMessage.className = 'message bot';
                errorMessage.textContent = '无法连接到AI服务，请检查API密钥或网络连接。';
                chatMessages.appendChild(errorMessage);
                chatMessages.scrollTop = chatMessages.scrollHeight;
            });

                    chatMessages.scrollTop = chatMessages.scrollHeight;
                }
            }

            chatButton.addEventListener('click', sendMessage);
            chatInput.addEventListener('keypress', function(e) {
                if (e.key === 'Enter') sendMessage();
            });
            const navItems = document.querySelectorAll('.nav-item');
            const contentDivs = document.querySelectorAll('.dashboard-card');

            // 为每个菜单项添加点击事件
            navItems.forEach(item => {
                item.addEventListener('click', function() {
                    // 移除所有菜单项的激活状态
                    navItems.forEach(nav => nav.classList.remove('active'));
                    // 添加当前菜单项的激活状态
                    this.classList.add('active');

                    // 隐藏所有内容板块
                    contentDivs.forEach(div => div.style.display = 'none');

                    // 获取当前菜单项对应的内容板块ID
                    const targetId = this.getAttribute('data-target');
                    const targetDiv = document.getElementById(targetId);
                    if (targetDiv) {
                        targetDiv.style.display = 'block';
                    }
                });
            });
        });
    </script>
</body>
</html>